package com.tchintech.pay.view.activity;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.view.View;

import com.tchintech.pay.R;
import com.tchintech.pay.delegate.SpeedyDelegate;
import com.tchintech.pay.frame.presenter.ActivityPresenter;
import com.tchintech.pay.model.entity.HttpCode;

/**
 * Created by Administrator on 2017/8/21 0021.
 * <p>
 * <p>
 * 便民服务
 */
public class SpeedyActivity extends ActivityPresenter<SpeedyDelegate> implements View.OnClickListener {
    private Intent intent = new Intent();
    private Handler handler;

    @Override
    protected void initView() {
        super.initView();
        viewDelegate.setTv_title("便民服务");
        viewDelegate.setOnClickListener(this, R.id.iv_back, R.id.real_rel_charge, R.id.real_flow, R.id.real_wz, R.id.real_carService, R.id.real_zsh
                , R.id.real_qp, R.id.real_kdjf, R.id.real_dfjf, R.id.real_ghjf, R.id.real_mqjf, R.id.real_sfjf, R.id.real_jfjl, R.id.real_helpcenter);
        handler();
    }

    private void handler() {
        handler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                hideProgressDialog();
                switch (msg.what) {
                    case HttpCode.networkabnormal:
                        showMsg("当前网络不可用");
                        break;
                    case HttpCode.http_failed:
                        showMsg("连接失败");
                        break;
                    case HttpCode.http_timeout:
                        showMsg("请求超时");
                        break;
                }
            }
        };
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.real_rel_charge:
                // showMsg("话费充值");
                intent.setClass(this, TeleChargeActivity.class);
                startActivity(intent);
                break;
            case R.id.real_flow:
                //showMsg("流量充值");
                intent.setClass(this, FlowChargeActivity.class);
                startActivity(intent);
                break;
            case R.id.real_wz:
                //showMsg("违章");
                intent.setClass(this, BreakTrafficActivity.class);
                startActivity(intent);
                break;
            case R.id.real_zsh:
                //  showMsg("中石化");
                intent.setClass(this, PetroChinaActivity.class);
                intent.putExtra("type", 1);
                startActivity(intent);
                break;
            case R.id.real_qp:
                // showMsg("中石油");
                intent.setClass(this, PetroChinaActivity.class);
                intent.putExtra("type", 2);
                startActivity(intent);
                break;
         /* case R.id.real_carService:
                showMsg("机动车");
                break;
            case R.id.real_kdjf:
                showMsg("宽带缴费");
                break;
            case R.id.real_dfjf:
                showMsg("电费缴费");
                break;
            case R.id.real_ghjf:
                showMsg("固话缴费");
                break;
            case R.id.real_mqjf:
                showMsg("煤气缴费");
                break;
            case R.id.real_sfjf:
                showMsg("水费缴费");
                break;
            case R.id.real_jfjl:
                showMsg("缴费激励");
                break;
            case R.id.real_helpcenter:
                showMsg("帮助中心");
                break;*/
            default:
                showMsg("正在开发中，敬请期待...");
                break;

        }

    }

    @Override
    protected Class<SpeedyDelegate> getDelegateClass() {
        return SpeedyDelegate.class;
    }
}
